﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common;
using AnesSystem.ViewModels;
using AnesSystem.Models;
using AnesSystem.Model;
using AnesSystem.Udp;

namespace AnesSystem.Util
{
    public class HospitalReturnUtil
    {
        #region Variables
        private static HospitalReturnUtil _instance;

        #endregion


        #region Constructor
        public HospitalReturnUtil()
        {
        }


        #endregion


        #region Properties
        public static HospitalReturnUtil Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new HospitalReturnUtil();
                }
                return _instance;
            }

            set
            {
                _instance = value;
            }
        }

        #endregion


        #region 依赖属性


        #endregion


        #region Event


        #endregion


        #region PrivateMethods


        #endregion


        #region Public/ProtectedMethods
        /// <summary>
        /// 手术状态回传统一入口
        /// </summary>
        /// <param name="patientLink">需要回传的病人</param>
        public void ReturnOperStatus2His(PatientLinkModel patientLink)
        {
            if (patientLink == null)
            {
                return;
            }
            UdpModel udpModel = new UdpModel();
            udpModel.PatientId = patientLink.Id.ToString();
            udpModel.Zyh = patientLink.Patient.Zyh;
            udpModel.UpdateDate = DateTime.Now.ToString();
            udpModel.AccountID = DataManager.Instance.Login.WorkID;
            if (DataManager.Instance.CurrentHospital.HospitalCode.Equals(HospitalConfig.HOSPITAL_CODE_SC_CD_WJZYY))
            {
                UdpMangager.Instance.SendUdpServerMsg(ServiceSign.OPERATION_STATUS_UPDATE, udpModel);
            }
            if (DataManager.Instance.CurrentHospital.HospitalCode.Equals(HospitalConfig.HOSPITAL_CODE_CQ_FYBJY))
            {
                UdpMangager.Instance.SendUdpServerMsg(ServiceSign.OPERATION_STATUS_UPDATE, udpModel);
            }
            if (DataManager.Instance.CurrentHospital.HospitalCode.Equals(HospitalConfig.HOSPITAL_CODE_CQ_TLRMYY))
            {
                UdpMangager.Instance.SendUdpServerMsg(ServiceSign.OPERATION_STATUS_UPDATE, udpModel);
            }
        }

        public void ReturnOperSecheduled2His(PatientLinkModel patientLink)
        {
            if (patientLink == null)
            {
                return;
            }
            UdpModel udpModel = new UdpModel();
            udpModel.PatientId = patientLink.Id.ToString();
            udpModel.Zyh = patientLink.Patient.Zyh;
            udpModel.UpdateDate = DateTime.Now.ToString();
            udpModel.AccountID = DataManager.Instance.Login.WorkID;
            if (DataManager.Instance.CurrentHospital.HospitalCode.Equals(HospitalConfig.HOSPITAL_CODE_CQ_FYBJY))
            {
                UdpMangager.Instance.SendUdpServerMsg(ServiceSign.PAIBANHUICHUAN, udpModel);
            }
        }

        #endregion


        #region EventHandlers


        #endregion
    }
}
